package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.ISysCommentService;
import com.ruoyi.system.service.ISysHotelService;
import com.ruoyi.system.service.ISysOrderService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.utils.StringUtils;

/**
 * 首页
 *
 * @author dht
 */
@RestController
public class SysIndexController
{
    /** 系统基础配置 */
    @Autowired
    private RuoYiConfig ruoyiConfig;
    @Autowired
    private ISysUserService userService;
    @Autowired
    private ISysOrderService orderService;
    @Autowired
    private ISysHotelService hotelService;
    @Autowired
    private ISysCommentService commentService;

    /**
     * 访问首页，提示语
     */
    @RequestMapping("/")
    public String index()
    {
        return StringUtils.format("欢迎使用{}后台管理框架，当前版本：v{}，请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
    }

    @GetMapping("/dashboard")
    public AjaxResult dashboard() {
        AjaxResult resp = new AjaxResult();
        resp.put("userCount", userService.selectCount());
        resp.put("orderCount", orderService.selectCount());
        resp.put("hotelCount", hotelService.selectCount());
        resp.put("commentCount", commentService.selectCount());
        resp.put("orderTrendList", orderService.selectOrderTrendList());
        resp.put("orderTypeList", orderService.selectOrderTypeList());
        return resp;
    }
}
